﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Xml;
using System.Xml;

using Jungle.Code.Core;
using Jungle.Code.Utils;

namespace PRVIgroup.Modules.LangHeader
{
    public partial class LangHeader : System.Web.UI.UserControl
    {
        private string ControlPath = "/Modules/LangHeader";
        // ---------------------------------------------------------------------------
        protected override void OnInit(EventArgs e)
        {
            LoadLanguage();
            base.OnInit(e);
        }
        // ---------------------------------------------------------------------------
        private void LoadLanguage()
        {
            int LangId = Node.GetByUrl(UrlHelper.GetRequestUrl().Substring(0, UrlHelper.GetRequestUrl().IndexOf(".aspx")).Replace("/main", "")).LangID;
            Language l = new Language(LangId,"","",true, 0); l.GetById();

            XmlDocument langDoc = new XmlDocument();

            if (l.Name != "ru")
            {
                langDoc.Load(Server.MapPath(ControlPath + "/langs/" + l.Name + ".xml"));
                foreach (XmlNode node in langDoc.ChildNodes[1].ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "hp_1": hp_1.Text = node.InnerText; break;
                        case "hp_2": hp_2.Text = node.InnerText; break;
                        case "hp_3": hp_3.Text = node.InnerText; break;
                        case "hp_4": hp_4.Text = node.InnerText; break;
                    }
                }
            }
        }
    }
}